package com.baigt.j8.lambda;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;

/**
 * java.util.function.Consumer
 * Represents an operation that accepts a single input argument and returns no result
 * 表示只接受一个入参，并且无返回结果(void)
 * Consumer<T>
 *     T 输入行为(操作)
 */
public class _005ConsumerDemo {

    public static void main(String[] args) {
     Print("Hello",t->System.out.println(t));
        Consumer<String> sendMQ = t -> {
            System.out.println("sendMQ="+t);
        };
        sendMQ.accept("Success");
        System.out.println("--------------------");
        sendMQ.andThen(System.out::println).accept("Success");
        System.out.println("--------------------");
        List<String> list = Arrays.asList("Hello", "World","baigt");
        list.stream().forEach(System.out::println);
        List<String> listnew=new ArrayList<>();
        list.stream().forEach(listnew::add);
        System.out.println(listnew.size());
    }

    public static void Print(String t,Consumer<String> consumer){
        consumer.accept(t);
    }
}
